package response

import (
	"ahutoj/web/dao"
	"ahutoj/web/io/constanct"
)

type LoginResp struct {
	Response
	Token string `json:"Token"`
	Uname string `json:"UserName"`
	UID   string `json:"UID"`
	PermissionMap int `json:"PermissionMap"`
}

type RegisterResp LoginResp

type UserResp struct {
	Response
	UID            string `json:"UID"`
	Uname          string `json:"UserName"`
	School         string `json:"School"`
	Classes        string `json:"Classes"`
	Year           string `json:"Year"`
	Major          string `json:"Major"`
	AtcoderUser    string `json:"AtcoderUser"`
	AtcoderScore   int    `json:"AtcoderScore"`
	Signature      string `json:"Signature"`
	NowcoderUser   string `json:"NowcoderUser"`
	NowcoderScore  int    `json:"NowcoderScore"`
	Vjid           string `json:"Vjid"`
	Email          string `json:"Email"`
	CodeForceUser  string `json:"CodeForceUser"`
	CodeForceScore int    `json:"CodeForceScore"`
	QQ             string `json:"QQ"`
	HeadURL        string `json:"HeadURL"`
	Submited       int64  `json:"Submited"`
	Solved         uint32 `json:"Solved"`
	Rating         int    `json:"Rating"`
	RegisterTime   int64  `json:"RegisterTime"`
	Status         int    `json:"Status"`
}
type AddUsersItem struct {
	UID      string `json:"UID"`
	Uname    string `json:"UserName"`
	School   string `json:"School"`
	Password string `json:"Password"`
}
type AddUsersResp struct {
	Response
	CreateNumber int         `json:"CreateNumber"`
	Data         []AddUsersItem `json:"Data"`
}


type GetUsersItem struct {
	UID      string `json:"UID"`
	Uname    string `json:"UserName"`
	School   string `json:"School"`
	Classes  string `json:"Classes"`
	Major    string `json:"Major"`
	Year     string `json:"Year"`
}
type GetUsersResp struct {
	Response
	Data         []GetUsersItem `json:"Data"`
}

type UserStatusInfoItem struct {
	PID        string             `json:"PID"`
	SubmitTime int64              `json:"SubmitTime"`
	Result     constanct.OJResult `json:"Result"`
}
type UserStatusInfoResp struct {
	Response
	Data []UserStatusInfoItem `json:"Data"`
}

func CreateUserResp(user *dao.User) UserResp {
	return UserResp{
		Response:       CreateResponse(constanct.SuccessCode),
		UID:            user.UID,
		Uname:          user.Uname,
		School:         user.School,
		Classes:        user.Classes,
		Major:          user.Major,
		Vjid:           user.Vjid,
		AtcoderUser:    user.AtcoderUser,
		AtcoderScore:   user.AtcoderScore,
		NowcoderUser:   user.NowcoderUser,
		NowcoderScore:  user.NowcoderScore,
		CodeForceScore: user.CodeForceScore,
		Signature:      user.Signature,
		Year:           user.Year,
		CodeForceUser:  user.CodeForceUser,
		HeadURL:        user.HeadURL,
		Submited:       user.Submited,
		Solved:         user.Solved,
		Rating:         user.Rating,
		RegisterTime:   user.RegisterTime,
		Status: 		constanct.Offline,
		Email:          user.Email,
	}
}

type VerifyEmailResp struct {
	Response
}

type EditHeadImageResp struct {
	Response
	ImageURL string `json:"ImageURL"`
}

type UserStatusListResp struct {
	Response
    UIDs *[]string `json:"UIDs"`
	Count int `json:"Count"`
}

type QQAuthResp struct {
	Response
	URL string `json:"URL"`
}

type QQInfoResp struct {
	Response
	UserInfo QQInfoItem `json:"UserInfo"`
}

type QQLoginResp struct{
	Response
	Token string `json:"Token"`
}

type QQInfoItem struct{
	QQ string `json:"QQ"`
	Uname string `json:"Uname"`
	Email string `json:"Email"`
}

type GetUserSolutionListResp struct {
	Response
	Solutions *[]GetUserSolutionListItem `json:"Solutions"`
}

type GetUserSolutionListItem struct {
	SID           int64  `gorm:"column:SID"`
	PID           string `gorm:"column:PID"`
	Title         string `gorm:"column:Title"`
	Text          string `gorm:"column:Text"` //内容
	CreateTime    int64  `gorm:"column:CreateTime;not null;comment:创建时间"`
	UpdateTime    int64  `gorm:"column:UpdateTime;not null;comment:更新时间"`
}

type AddGroupResp struct {
	Response
	GID int64 `json:"GID"`
}

type DeleteGroupResp struct {
	Response
}

type EditGroupResp struct {
	Response
}


type GetGroupListResp struct {
	Response
	Groups *[]GetGroupListItem  `json:"Groups"`
}

type GetGroupListItem struct {
	GID        int64  `json:"GID"`
    GroupName  string `json:"GroupName"`
    UID        string `json:"UID"`// 创建者UID
    CreateTime int64  `json:"CreateTime"`
	JoinTime   int64  `json:"JoinTime"`
    InviteCode string `json:"InviteCode,omitempty"`
}

type GetGroupResp struct {
	Response
	GID        int64  `json:"GID"`
    GroupName  string `json:"GroupName"`
    GroupTask  string `json:"GroupTask"`
    UID        string `json:"UID"`// 创建者UID
    CreateTime int64  `json:"CreateTime"`
    InviteCode string `json:"InviteCode,omitempty"`
	MemberUIDs []string `json:"MemberUIDs"`
}

type AddUserToGroupResp struct {
	Response
}

type DeleteUserFromGroupResp struct {
	Response
}

type JoinGroupResp struct {
	Response
}

type QuitGroupResp struct {
	Response
}

type GetGroupTraceResp struct {
	Response
	Trace map[string]GetUserGroupTraceItem `json:"Trace"`
}

type GetUserGroupTraceItem struct {
	UserName   string `json:"UserName"`
	LIDTrace []GroupLIDTraceItem `json:"LIDTrace"`
	CIDTrace []GroupCIDTraceItem `json:"CIDTrace"`
	PIDTrace []GroupPIDTraceItem `json:"PIDTrace"`
}

type GroupLIDTraceItem struct {
	LID int64 `json:"LID"`
	PID string `json:"PID"`
	SID int64  `json:"SID"`
}

type GroupCIDTraceItem struct {
	CID int64 `json:"CID"`
	PID string `json:"PID"`
	SID int64 `json:"SID"`
}

type GroupPIDTraceItem struct {
	PID string `json:"PID"`
	SID int64 `json:"SID"`
}

